{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "d907ac28-a53b-4969-accd-4cf8da59be27",
   "metadata": {},
   "source": [
    "ASCII 码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "63e54719-714b-457e-afb9-ce722a2db182",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "100"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x=ord('b') # 把字符转成ASCII码\n",
    "x+=2\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "ddd5f6f4-ac7c-4d5e-bb41-e8afa3e973e4",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'d'"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a=chr(x) # ASCII转成对应的字符\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "73b5d2f3-6e30-4931-b5a2-bc8aed716d9e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "32"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ord('y')-ord('Y')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "c68a6854-e5b2-48c7-bfec-26e362d73171",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'a'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c='A'\n",
    "chr(ord(c)+ord('r')-ord('R'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "29663847-b521-42fe-a767-d93448d1e8a5",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a='b'\n",
    "ord('a')<=ord(a)<=ord('z')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "e6da1fda-7c68-4f93-a926-6e4bdba321eb",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'a'<=a<='z'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "6418ef9e-8c66-42f8-b924-1ad4cb531518",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "32"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ord('a')-ord('A')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "f34f3972-0259-4560-a80a-b9da5cd33308",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Ԗ'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chr(1302)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
